package com.itheima.sh.client;

import com.itheima.sh.client.fallback.UserFeignApiFallBack;
import com.itheima.sh.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Description:  feign对Ribbon封装
 * @Version: V1.0
 */
@FeignClient(value = "user-service", fallback = UserFeignApiFallBack.class)   // feign 客户端， 远程调用user-service 服务
@Primary
public interface UserFeignApi {

    /**
     * 接口方法是参考服务提供方编写
     * 注意：请求路径完整性， 类上的注解
     * @param username
     * @return
     */
    @GetMapping("/user/{id}")
    public User queryById(@PathVariable("id") String username);

}
